import { View, Text, Button } from '@tarojs/components'
import React, { useState, useRef, useEffect } from 'react'
import Taro from '@tarojs/taro'

function MyTest(props) {
    const ref = useRef(null);
    useEffect(() => {
        ref.current = Taro.getCurrentInstance();
        console.log(ref);
    }, [])

    const [number, setnumber] = useState(0)
    function gotoIndex(e) {
        // Taro.navigateTo({
        //     url: "/pages/index/index"
        // })

        // 带参数传递
        Taro.navigateTo({
            url: "/pages/index/index?number=" + number
        })

        // Taro.redirectTo({url: "/pages/index/index"})
    }
    return (<View>
        <Text>
            <div className="module">
                MyTest Page
                {
                    ref.current && `页面传入参数: ${ref.current.router.params.from}`
                }
                <Button onClick={gotoIndex}> 回到首页 </Button>
            </div>
            <div className="module">
                引入图片 使用Image组件

            </div>
        </Text>
    </View>)
}

export default MyTest